qtemp_big=Qgov;

parfor j=1:NSS %Today's Exogenous Shock
           for t=1:NB %Today's private debt index;                     
                for i=1:NBG %Today's public Debt shock
 
                            [x,BGip_big(i,t,j)]=max(G_big(i,t,j,:));                           

                 end
           end
 end
  parfor j=1:NSS %Today's Exogenous Shock
           for t=1:NB %Today's private debt index;                     
                for i=1:NBG %Today's public Debt shock
                             EBGp(i,t,j)=BGgrid(BGip_big(i,t,j));                          

 
                 end
           end
  end
 
  EQ=zeros(NBG,NB,NSS);
 parfor j=1:NSS %Today's Exogenous Shock
           for t=1:NB %Today's private debt index;                     
                for i=1:NBG %Today's public Debt shock
                  
                    Ebp(i,t,j)=interp1(BGgrid,squeeze(bp(i,t,j,:)),EBGp(i,t,j),'linear','extrap');
                     EQ(i,t,j)=interp1(BGgrid,squeeze(Qgov(i,t,j,:)),EBGp(i,t,j),'linear','extrap');
                    ETau(i,t,j)=interp1(BGgrid,squeeze(Tau1p(i,t,j,:)),EBGp(i,t,j),'linear','extrap');
                 end
           end
 end

A=isnan(EQ);

